/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.sun.courier.model;

import java.util.Vector;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author HONG QUAN
 */
public class EmployeeModel extends AbstractTableModel{
    Vector columnNames = new Vector();
    public Vector data = new Vector();
    
    public Vector delEmpId = new Vector();
    public Vector insEmpId = new Vector();
    public Vector updEmpId = new Vector();

    public EmployeeModel() {
//        columnNames.add("Empoyee Id");
        columnNames.add("Employee Name");
        columnNames.add("Address");
        columnNames.add("Email");
        columnNames.add("Phone");
        columnNames.add("Image");
        columnNames.add("Position");
//        columnNames.add("Department Id");
    }

    @Override
    public int getRowCount() {
        return data.size();
    }

    @Override
    public int getColumnCount() {
        return columnNames.size();
    }

    @Override
    public Object getValueAt(int row, int col) {
        return ((Vector) data.get(row)).get(col);
    }

    @Override
    public void setValueAt(Object value, int row, int col) {
        Integer bookCode = (Integer) ((Vector) data.get(row)).get(0);
        if (!insEmpId.contains(bookCode)) // neu chua ton tai trong ds insert
        	updEmpId.add(bookCode);
        
        ((Vector) data.get(row)).set(col, value);       
        this.fireTableCellUpdated(row, col);
    }

    @Override
    public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }

    @Override
    public String getColumnName(int col) {
        return (String) columnNames.get(col);
    }
}
